package com.wu.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wu.dao.UserDao;
import com.wu.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserDao userDao;

    //查询一个
    @RequestMapping("/findone/{id}")
    public User findById(@PathVariable("id") int id){
        return userDao.selectById(id);
    }

    //更新一个
    @RequestMapping("/updateone/{id}")
    public int updateById(@PathVariable("id") int id){
        return userDao.updateById(userDao.selectById(id).setName("李四光").setAge(123));
    }

    //查询全部
    @RequestMapping("/findall")
    public List<User> updateById(){
        return userDao.findAll();
    }

    //测试接口注解
    @RequestMapping("/findstudent/{id}")
    public User findstudent(@PathVariable("id") int id){
        return userDao.findstudent(id);
    }

}
